package com.fp.m7.shared;

import java.io.Serializable;

/**
 * Defines a validation error with a erronous fieldname and the message (template).
 * 
 * @author 7
 */
public class ValidationError implements Serializable {
    private static final long serialVersionUID = 8752197938380822886L;

    private String fieldName;
    private String errorMessage;

    public ValidationError() {
    }

    public ValidationError(String fieldName, String errorMessage) {
        this.fieldName = fieldName;
        this.errorMessage = errorMessage;
    }

    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null || !(obj instanceof ValidationError)) {
            return false;
        }
        ValidationError that = (ValidationError) obj;
        if (this.fieldName == null ? that.fieldName != null : !this.fieldName.equals(that.fieldName)) {
            return false;
        }
        if (this.errorMessage == null ? that.errorMessage != null : !this.errorMessage.equals(that.errorMessage)) {
            return false;
        }
        return true;
    }
}
